namespace DukeyTbker.API {
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Text;

    public class CSVHelper {
        public static List<string[]> ReadCSV(string filePathName) {
            List<string[]> list = new List<string[]>();
            StreamReader reader = new StreamReader(filePathName, Encoding.Default);
            string str = "";
            while (str != null) {
                str = reader.ReadLine();
                if ((str != null) && (str.Length > 0)) {
                    str = str.Replace("\"", "");
                    list.Add(str.Split(new char[] { ',' }));
                }
            }
            reader.Close();
            return list;
        }

        public static void WriteCSV(string filePathName, List<string[]> list_0) {
            WriteCSV(filePathName, false, list_0);
        }

        public static void WriteCSV(string filePathName, bool append, List<string[]> list_0) {
            StreamWriter writer = new StreamWriter(filePathName, append, Encoding.Default);
            foreach (string[] strArray in list_0) {
                writer.WriteLine(string.Join(",", strArray));
            }
            writer.Flush();
            writer.Close();
        }
    }
}

